<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>GridSolver - Beta</title>
        <h:outputStylesheet name="css/jsfcrud.css"/>        
    </h:head>
    <h:body> 
        <div id="menu" class="menu">
            <div class="menuitem">
            <h:link outcome="/aluno/List" value="Editar Alunos"/>
            </div>
            <div class="menuitem">
            <h:link outcome="/curso/List" value="Editar Cursos"/>
            </div>
            <div class="menuitem">
            <h:link outcome="/materia/List" value="Editar Materias"/>
            </div>
        </div>
        
        <div id="aluno" class="alunoForm">
            <h:form>                
                <h:selectOneMenu value="#{cspTestBean.idAluno}" styleClass="selector">
                    <c:forEach var="aluno" items="#{cspTestBean.listAlunos()}">
                        <f:selectItem itemLabel="#{aluno.nome}" itemValue="#{aluno.idAluno}"/>                        
                    </c:forEach>
                </h:selectOneMenu>
                <h:selectOneMenu value="#{cspTestBean.idCurso}" styleClass="selector" >
                    <c:forEach var="curso" items="#{cspTestBean.listCursos()}">
                        <f:selectItem itemLabel="#{curso.descricao}" itemValue="#{curso.idCurso}"/>
                    </c:forEach>
                </h:selectOneMenu>
                <h:commandButton action="#{cspTestBean.fillTSPData()}" value="Planejar" />
            </h:form>              
        </div>

        <div id="resultados">
            <c:choose>
                <c:when test="#{cspTestBean.feasible}">
                    <c:forEach items="#{cspTestBean.schedule}" var="ano" varStatus="anoLoop">
                        <br />
                        <table border="1" class="scheduleTable">
                            <tr>
                                <th colspan="7" height="25">
                                    <h:outputLabel value="Ano: #{anoLoop.index + cspTestBean.minAno}" />                           
                                </th>
                            </tr>                
                            <c:forEach items="#{ano}" var="semestre" varStatus="semLoop">
                                <tr>
                                    <th rowspan="4" width="50">
                                        <h:outputLabel value="Semestre: #{semLoop.index + 1}" />
                                    </th>                                    
                                    <c:forEach items="#{semestre}" var="periodo" >
                                        <tr>                                            
                                            <c:forEach items="#{periodo}" var="nome" >
                                                <td align="center" width="200" height="25">
                                                    <h:outputLabel value="#{nome}" />
                                                </td>
                                            </c:forEach>                                   
                                        </tr>                              
                                    </c:forEach>
                                </tr>
                            </c:forEach>
                        </table>
                    </c:forEach>
                </c:when>
                <c:otherwise>
                    <h:outputLabel value="Não há soluções." />
                </c:otherwise>
            </c:choose>
        </div>

    </h:body>



</html>

